<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>React-Template</title>
    <link rel="stylesheet" href="../css/main.css">
    <script src="../js/react.min.js"></script>
    <script src="../js/react-dom.min.js"></script>
    <script src="../js/browser.min.js"></script>
</head>
<body>
    <!-- container -->
    <div id="container"></div>
    <script type="text/babel">
        var CheckBox=React.createClass({
            // init a state
            getInitialState:function () {
              return {
                  checked:true
              }  
            },
            handleChecked:function(){
                this.setState({checked:!this.state.checked});
            },
            render:function () {
                var msg;
                if(this.state.checked){
                    msg="checked";
                }else{
                    msg="unchecked";
                }
                return (
                    <div>
                        <input type="checkbox" defaultChecked={this.state.checked} onChange={this.handleChecked}/>
                        <h3>Checkbox is {msg}</h3>
                        <p>{this.props.title}</p>
                    </div>
                );
            }
        });


        ReactDOM.render(
            <CheckBox title="attribute"/>,
            document.getElementById('container')
        );
    </script>
</body>
</html>
